package day16;

//抽象工厂模式
public interface AbstractFactory {
    ProductA createObjectA();
    ProductB createObjectB();
    //ProductC createObjectC();
}
//具体工厂1 负责生产高配对象
class Factory1 implements AbstractFactory{
    public ProductA createObjectA() {
        return new GoodsA1();
    }

    public ProductB createObjectB() {
        return new GoodsB1();
    }
}
class Factory2 implements AbstractFactory{
    public ProductA createObjectA() {
        return new GoodsA2();
    }

    public ProductB createObjectB() {
        return new GoodsB2();
    }

    public static void main(String[] args) {
        AbstractFactory factory2=new Factory2();
        ProductA pA=factory2.createObjectA();
        ProductB pB=factory2.createObjectB();
        pA.product();
        pB.product();
    }
}

//商品对象
//抽象商品A
interface ProductA{
    void product();
}
//具体商品A1
class GoodsA1 implements ProductA{
    public void product() {
        System.out.println("生产A1商品（高配）");
    }
}
class GoodsA2 implements ProductA{
    public void product() {
        System.out.println("生产A1商品（高配）");
    }
}
interface ProductB{
    void product();
}
//具体商品B1
class GoodsB1 implements ProductB{
    public void product() {
        System.out.println("生产B1商品（高配）");
    }
}
class GoodsB2 implements ProductB{
    public void product() {
        System.out.println("生产B1商品（高配）");
    }
}